Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

@ms-cloudpack/telemetry

Package Overview
Dependencies
Maintainers
0
Versions
50
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@ms-cloudpack/telemetry

Helpers for reporting telemetry in Cloudpack.

  • 0.9.6
  • latest
  • npm
  • Socket score

Version published
Weekly downloads
133
decreased by-77.07%
Maintainers
0
Weekly downloads
 
Created
Source

@ms-cloudpack/telemetry

A library for telemetry that gets reported to Application Insights by using Open Telemetry standards.

Currently, this library only supports Tracing. Metrics and Logs can be added later when needed.

Example usage

  1. Create a client:
const telemetryClient = new TelemetryClient({
  serviceNamespace: 'cloudpack',
  serviceName: 'cli',
  productVersion: '1.2.3',
  instrumentationKey: '<Application insights Instrumentation Key>',
  logLevel: 'verbose',
});
  1. Add shared attributes
telemetryClient.setSharedSpanAttribute('sessionId', 'my-session-id');

These attributes will get added to all spans.

  1. Get the tracer
const tracer = telemetryClient.getTracer();
  1. Create a span / add events / end the span
const span = tracer.createSpan('my-unit-of-work');
// do work
span.addEvent('my-event', { myCustomAttribute: 'my-custom-value' });

try {
  // do more work
} catch (err) {
  span.recordException(err);
}

// end the span when the unit-of-work completed.
span.end();

Lear more about spans

  1. Shutdown TelemetryClient before application exists
telemetryClient.shutdown();
  • This will force flush all the remaining data to remote servers and prevent more data to be collected.
  • Make sure that all spans have been ended before shuting down the telemetry client

FAQs

Package last updated on 14 Nov 2024

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc